package com.yunzhong.appointment.report.controller;

import com.yunzhong.appointment.report.service.IAnnualAppointmentStatisticsService;
import com.yunzhong.appointment.report.service.IAnnualDepartmentAppointmentStatisticsService;
import org.apache.jasper.tagplugins.jstl.core.ForEach;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.*;

/**
 * 
 * @className AnnualAppointmentStatisticsController
 * @description 年预约统计
 * @author 朱洪宇
 * @time 2019年12月18日
 */
@RequestMapping("forms")
@Controller
public class AnnualAppointmentStatisticsController {
	@Autowired
	private IAnnualAppointmentStatisticsService iAnnualAppointmentStatisticsService;
	/**
	 *
	 * @methodName appointment
	 * @description 转页
	 * @author 朱洪宇
	 * @time 2019年12月20日
	 */
	@RequestMapping("appointment")
	public  String deptapp(ModelMap mm){
//		List<Map<String, Object>> list =iAnnualAppointmentStatisticsService.queryCount();
//		Map<String, Long> map = new LinkedHashMap<>();
//		for( Map<String, Object> m : list) {
//			map.put(String.valueOf(m.get("name")), (Long)m.get("num"));
//		}
//		List<String> data1=new LinkedList<String>();
//		List<Long> data2=new LinkedList<Long>();
//		for (String key:map.keySet()) {
//			data1.add(key);
//			data2.add(map.get(key));
//		}
//		mm.put("data1",data1);
//		mm.put("data2",data2);
		return "report/report/annualappointmentstatistics";
	}

	/**
	 *
	 *@methodName queryAjax
	 *@description 查询年预约数
	 *@author 朱洪宇
	 *@time 2019年12月20日
	 *
	 * @return map
	 */
	@RequestMapping("queryAjax")
	@ResponseBody
	public  Map<String,Long> queryAjax(String data){
		List<Map<String, Object>> list =iAnnualAppointmentStatisticsService.queryCount();
		Map<String, Long> map = new LinkedHashMap<>();
		for( Map<String, Object> m : list) {
			map.put(String.valueOf(m.get("name")), (Long)m.get("num"));
		}
		return map;
	}



}
